﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Hisun.Models;

namespace Hisun.Controllers
{
    public class FullDriver
    { 
        
        //定义全局变量
        HisunDBDataContext db = new HisunDBDataContext();


        public string MeterialMoney_TR(string ProductId, string Ap)
        { 
           string tr = "0";

           var Query_MeterialMoney_TR = from a in db.VABC_Report_PiPMeterialsCost_不含中间体信息
                                        where a.产品ID == ProductId && a.会计期间ID == Ap
                                        select a.投入金额;

            if(Query_MeterialMoney_TR.Count() > 0)
            {
                tr = Math.Round(Query_MeterialMoney_TR.Sum().Value,2,MidpointRounding.AwayFromZero).ToString();
            }

            return tr;
        }


        public string HumanMoney_TR(string PiPId, string Ap)
        {
            string tr = "0";

            var Query_HumanMoney_TR = from a in db.VABC_Report_PiPActiveCost_不含中间体信息
                                          where a.中间体ID == PiPId  && a.会计期间ID == Ap && a.成本细项ID == "RG"
                                          select a.投入金额;

            if (Query_HumanMoney_TR.Count() > 0)
            {
                tr = Math.Round(Query_HumanMoney_TR.Sum(),2,MidpointRounding.AwayFromZero).ToString();
            }

            return tr;
        }
    }
}
